﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodCaching.Weaving.Extensions;
using Mono.Cecil;

namespace MethodCaching.Weaving
{
    /// <summary>
    /// A <see cref="ITypeSelector"/> implementation that selects 
    /// types decorated with the <see cref="EnableMethodCachingAttribute"/> 
    /// </summary>
    public class AttributeTypeSelector : LambdaTypeSelector
    {        
        /// <summary>
        /// Initializes a new instance of the <see cref="AttributeMethodSelector"/> class.
        /// </summary>
        public AttributeTypeSelector()
            : base(t =>
                       {
                           TypeReference attributeType = t.Module.Import(typeof (EnableMethodCachingAttribute));
                           return t.IsDefined(attributeType);
                       }){}                
    }
}
